package net.net23.sysdent.server.jdo.control.search.model;

import java.util.HashSet;
import java.util.Set;

public class SearchJanitor {

	public static final int MAXIMUM_NUMBER_OF_WORDS_TO_SEARCH = 5;

	public static final int MAX_NUMBER_OF_WORDS_TO_PUT_IN_INDEX = 200;

	public static Set<String> updateKeyWordsForSearchableEntity(
			DbEntity searchableEntity) {
		StringBuffer sb = new StringBuffer();
		sb.append(searchableEntity.getSearchField());
		Set<String> newKeyWords = SearchJanitorUtils
				.getTokensForIndexingOrQuery(sb.toString(),
						MAX_NUMBER_OF_WORDS_TO_PUT_IN_INDEX);
		Set<String> keyWords = new HashSet<String>();
		keyWords.clear();
		for (String token : newKeyWords) {
			keyWords.add(token);
		}
		return keyWords;
	}

}
